package com.skycong.hello77.common.baseadpater;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.skycong.hello77.R;

/**
 * Created by Kiki on 2018/6/19.
 */

public class BaseView {
    public View viewTop;//顶部页面
    public View layout_back;//返回布局
    public TextView tv_title;//标题
    public View viewNoData;//数据加载失败的页面
    public ImageView iv_nodata;//没有数据时的图片提示
    public TextView tv_nodata;//没有数据的文字提示
    public TextView tv_networknot;//没有数据的文字提示
    public TextView btn_nodata;//没有数据最下面按钮

    public BaseView(Context context) {
        Activity view = (Activity) context;
        this.viewTop = view.findViewById(R.id.layout_top);
        this.viewNoData = view.findViewById(R.id.layout_nodata);
        this.layout_back = view.findViewById(R.id.layout_back);
        this.tv_title = (TextView) view.findViewById(R.id.tv_title);
        this.iv_nodata = (ImageView) view.findViewById(R.id.iv_nodata);
        this.tv_nodata = (TextView) view.findViewById(R.id.tv_nodata);
        this.tv_networknot = (TextView) view.findViewById(R.id.tv_networknot);
        this.btn_nodata = (TextView) view.findViewById(R.id.btn_nodata);
    }

    public BaseView(View view) {
        this.viewTop = view.
                findViewById(R.id.layout_top);
        this.viewNoData = view.findViewById(R.id.layout_nodata);
        this.layout_back = view.findViewById(R.id.layout_back);
        this.tv_title = (TextView) view.findViewById(R.id.tv_title);
        this.iv_nodata = (ImageView) view.findViewById(R.id.iv_nodata);
        this.tv_nodata = (TextView) view.findViewById(R.id.tv_nodata);
        this.tv_networknot = (TextView) view.findViewById(R.id.tv_networknot);
        this.btn_nodata = (TextView) view.findViewById(R.id.btn_nodata);
    }

    public void setListener(View.OnClickListener listener) {
        if (layout_back != null) {
            this.layout_back.setOnClickListener(listener);
        }
        if (iv_nodata != null) {
            this.iv_nodata.setOnClickListener(listener);
        }
        if (tv_nodata != null) {
            this.tv_nodata.setOnClickListener(listener);
        }
    }

    public void setTitle(String title) {
        if (tv_title != null) {
            this.tv_title.setText(title);
        }
    }

}
